// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   VideoChooser.java

package presenter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.*;

// Referenced classes of package presenter:
//            SongFile

public class VideoChooser extends JPanel
    implements ActionListener
{

    public VideoChooser()
    {
        update = false;
        change = new JButton("Change Video");
        change.addActionListener(this);
        add(change);
        output = new JLabel();
        add(output);
    }

    public boolean isUpdated()
    {
        if(update)
        {
            update = false;
            return true;
        } else
        {
            return false;
        }
    }

    public void setSong(SongFile song)
    {
        this.song = song;
        if(song.hasVideo())
        {
            output = new JLabel((new StringBuilder()).append("Current Video ").append(song.getVideo().substring(9)).toString());
            add(output);
            update = true;
        }
    }

    public void actionPerformed(ActionEvent e)
    {
        chooser = new JFileChooser(new File("Videos"));
        int returnVal = chooser.showOpenDialog(this);
        if(returnVal == 0)
        {
            String path = (new StringBuilder()).append("./Videos/").append(chooser.getSelectedFile().getName()).toString();
            song.setVideo(path);
            remove(output);
            output = new JLabel((new StringBuilder()).append("Current Video ").append(chooser.getSelectedFile().getName()).toString());
            add(output);
            update = true;
        }
    }

    private boolean update;
    private SongFile song;
    private JFileChooser chooser;
    JButton change;
    JLabel output;
}
